/**
 * Copyright By Nanjing Fujitsu Nanda Software Technology Co., Ltd
 * 上午10:12:32
 * CoreCompanyDao.java
 * 
 */
package com.fujitsu.nanjing.mobile.service;

import com.fujitsu.nanjing.mobile.dao.CoreCompanyDao;
import com.fujitsu.nanjing.mobile.exception.NotOneException;
import com.fujitsu.nanjing.mobile.model.hibernate.CoreCompany;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

import javax.annotation.Resource;

/**
 * @author qixb.fnst
 * 
 */
@Service
@Transactional
public class CoreCompanyService implements BaseService<CoreCompany> {
    @Resource
    private CoreCompanyDao coreCompanyDao;

    @Override
    public CoreCompany find(int id) {
        return coreCompanyDao.query(CoreCompany.class, id);
    }

    @Override
    public CoreCompany modify(CoreCompany t) {

        return coreCompanyDao.update(t);
    }

    @Override
    public void delete(CoreCompany t) {
        coreCompanyDao.delete(t);

    }

    @Override
    public CoreCompany add(CoreCompany t) {
        return coreCompanyDao.insert(t);
    }

    @Override
    public List<CoreCompany> find(String queryString) {
        return coreCompanyDao.query(queryString);
    }

    /**
     * qixib.fnst
     * 
     * @param whereClause
     * @return
     */
    public int getCompanyNums(String whereClause) {

        return coreCompanyDao.getCompanyNums(whereClause);
    }

    public List<CoreCompany> getCompanies(String orderClause,
            String whereClause, boolean userLimit, int firstRecord, int limit) {
        return coreCompanyDao.getCompanies(orderClause, whereClause, userLimit,
                firstRecord, limit);
    }

    /**
     * qixib.fnst
     * @param companyId
     * @return
     * @throws NotOneException 
     */
    public CoreCompany getCompanyByCompanyId(int companyId) throws NotOneException {
       
        return coreCompanyDao.getCompanyByCompanyId( companyId);
    }

}
